package com.amit.jsf;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;


@FacesValidator("jlcemail")
public class EmailValidator  implements Validator{

	@Override
	public void validate(FacesContext fc, UIComponent uic, Object value)
			throws ValidatorException {
		
		String em=value.toString();
		if(!em.endsWith("@jlc.com"))
		{
			FacesMessage fm=new FacesMessage("Username must end with @jlc.com");
			fc.addMessage("username", fm);
			
			throw new ValidatorException(fm);
		}
		
		
		
	}
	
	
	

}
